package com.sunwayhorizo.health.business.patad.encounter;

import com.sunwayhorizo.health.hl7.common.Hl7Exception;

import java.util.*;
import javax.ejb.*;

import com.sunwayhorizo.health.business.dto.ResultsDTO;
import com.sunwayhorizo.health.business.dto.patad.encounter.*;
import com.sunwayhorizo.health.hl7.persistent.*;
import com.sunwayhorizo.health.hl7.rim.*;

/**
 * 患者挂号，入院管理接口
 * 
 * @Title: CheckinManagerLocal
 * @Package com.sunwayhorizo.health.business.patientencounter
 * @version V1.0
 * @firstAuthor jinzw
 * @firstTime 2010-12-07 下午17:52:59
 * @lastAuthor jinzw
 * @lastTime 2010-12-07 下午17:52:59
 */

@Local
public interface CheckinManagerLocal {

	/**
	 * 患者挂号
	 * 
	 * @Title: newCheckIn
	 * @param @param patientEncounterDTO 患者挂号DTO与前台VO对应
	 * @param @return
	 * @param @throws Hl7Exception
	 * @return ResultsDTO 保存成功返回患者ID
	 * @throws Hl7Exception
	 * @firstAuthor jinzw
	 * @firstTime 2010-12-8 下午03:23:15
	 * @lastAuthor jinzw
	 * @lastTime 2010-12-8 下午01:50:04
	 */
	public ResultsDTO newCheckIn(PatientEncounterDTO patientEncounterDTO)
			throws Hl7Exception;

	/**
	 * 患者换号
	 * 
	 * @Title: transferClinic
	 * @param PatientEncounterDTO
	 *            patientEncounterDTO 患者挂号DTO
	 * @return ResultsDTO
	 * @throws Hl7Exception
	 * @firstAuthor jinzw
	 * @firstTime 2010-12-19 下午03:23:15
	 * @lastAuthor jinzw
	 * @lastTime 2010-12-19 下午01:50:04
	 */
	public ResultsDTO transferClinic(PatientEncounterDTO patientEncounterDTO)
			throws Hl7Exception;

	/**
	 * 患者退号
	 * 
	 * @Title: backNO
	 * @param PatientEncounterDTO
	 *            patientEncounterDTO 患者挂号DTO
	 * @return ResultsDTO
	 * @throws Hl7Exception
	 * @firstAuthor jinzw
	 * @firstTime 2010-12-19 下午03:23:15
	 * @lastAuthor jinzw
	 * @lastTime 2010-12-19 下午01:50:04
	 */
	public ResultsDTO backNO(PatientEncounterDTO patientEncounterDTO)
			throws Hl7Exception;

	/**
	 * 根据就诊卡ID查询患者基本信息
	 * 
	 * @param medicalCardId
	 *            就诊卡ID
	 * @return 患者基本信息DTO
	 * @throws Hl7Exception
	 */
	public ResultsDTO findPatientByMedCard(String medicalCardId)
			throws Hl7Exception;

	/**
	 * 根据就诊序号查询已挂号数
	 * 
	 * @param encounterNo
	 * @return
	 * @throws Hl7Exception
	 */
	public ResultsDTO findCheckInDetail(String encounterNo) throws Hl7Exception;

	/**
	 * 根据就诊号查询一次挂号
	 * 
	 * @Title: findCheckInById
	 * @param @param encounterId 就诊号
	 * @param @param actId Act ID
	 * @return PatientEncounter 一次就诊动作
	 * @throws Hl7Exception
	 * @firstAuthor jinzw
	 * @firstTime 2010-12-19 下午03:23:15
	 * @lastAuthor jinzw
	 * @lastTime 2010-12-19 下午01:50:04
	 */
	public PatientEncounter findCheckInById(String encounterId, String actId,
			String entounterType) throws Hl7Exception;

	/**
	 * 根据条件查询挂号集合
	 * 
	 * @Title: findCheckInByCond
	 * @param @param encounterId 就诊号
	 * @param @param actId Act ID
	 * @return List<PatientEncounter> 一次就诊动作集合
	 * @throws Hl7Exception
	 * @firstAuthor jinzw
	 * @firstTime 2010-12-19 下午03:23:15
	 * @lastAuthor jinzw
	 * @lastTime 2010-12-19 下午01:50:04
	 */
	public List<PatientEncounter> findCheckInByCond(String encounterId,
			String actId, String entounterType) throws Hl7Exception;

	/**
	 * 得到当前号
	 * 
	 * @param visitId
	 *            号表角色ID
	 * @return 已挂该科室或该医生的患者号数
	 * @throws Hl7Exception
	 */
	public Long findCountEncounter(String visitId) throws Hl7Exception;

	/**
	 * 根据就诊序号得到RimCoreActPrtcptns
	 * 
	 * @param encounterNo
	 *            就诊序号
	 * @return
	 * @throws Hl7Exception
	 */
	public RimCoreActPrtcptns findCheckInByEncounterNo(String encounterNo)
			throws Hl7Exception;

	/**
	 * 持久化挂号信息
	 * 
	 * @param patientEncounterDTO
	 * @return
	 * @throws Hl7Exception
	 */
	public PatientEncounterDTO persistCheckIn(
			PatientEncounterDTO patientEncounterDTO) throws Hl7Exception;

	/**
	 * 构造挂号DTO
	 * 
	 * @param act
	 *            挂号动作
	 * @param actPrtcptns
	 *            挂号动作与参与角色联系方式，可以默认为空
	 * @return
	 * @throws Hl7Exception
	 */
	public PatientEncounterDTO convertPatientEncounterDTO(Act act,
			ActParticipation actPrtcptns) throws Hl7Exception;

	/**
	 * 挂号中持久化一个患者信息
	 * 
	 * @param patientEncounterDTO
	 * @return
	 * @throws Hl7Exception
	 */
	public String persistPatient(PatientEncounterDTO patientEncounterDTO)
			throws Hl7Exception;

	/**
	 * 门诊接诊查询已挂在本工作组或者本人的所有患者
	 * 
	 * @param personId
	 *            接诊医生实体ID
	 * @param workGroupIds
	 *            接诊医生所在的工作组实体ID集合
	 * @param encounterType
	 *            就诊类型 此方法接收门诊跟急诊
	 * @return ResultsDTO
	 * @throws Hl7Exception
	 */
	public ResultsDTO findCheckInList(String personId, @SuppressWarnings("rawtypes") List workGroupIds,
			String encounterType) throws Hl7Exception;

	/**
	 * 根据患者ID查询出PatientEncounter
	 * 
	 * @param patientId
	 *            患者ID
	 * @return PatientEncounter
	 * @throws Hl7Exception
	 */
	public PatientEncounter findPatientEncounterByPatId(String patientId,
			String encounterType) throws Hl7Exception;

}
